package com.mall.sun.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.sun.model.dto.*;
import com.mall.sun.model.po.Goods;
import com.mall.sun.model.po.Goodscategory;
import com.mall.sun.repository.mapper.GoodsMapper;
import com.mall.sun.service.GoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Tansty
 * @since 2021-11-30
 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
    @Autowired
    GoodsMapper goodsMapper;
    @Override
    public GoodDTO[] getAllGood( PageHelper pageHelper) {
        Page<GoodDTO> goodDTOPage = new Page<GoodDTO>(pageHelper.getCurrentPage(),pageHelper.getPageSize());
        return goodsMapper.getAllGood(goodDTOPage);
    }

    @Override
    public Goodscategory[] getAllTypes() {
        return goodsMapper.getAllTypes();
    }

    @Override
    public GoodAgentDTO[] getGoodsAgent(PageHelper pageHelper) {
        Page<GoodAgentDTO> goodAgentDTOPage = new Page<>(pageHelper.getCurrentPage(), pageHelper.getPageSize());
        return goodsMapper.getGoodsAgent(goodAgentDTOPage);
    }

    @Override
    public GoodSupplierDTO[] getGoodsSuppier(PageHelper pageHelper) {
        Page<GoodSupplierDTO> goodSupplierDTOPage = new Page<>(pageHelper.getCurrentPage(), pageHelper.getPageSize());
        return goodsMapper.getGoodsSuppier(goodSupplierDTOPage);
    }

    @Override
    public int updateGood(GoodDTO goodDTO) {
        return goodsMapper.updateGood(goodDTO);
    }

    @Override
    public Long countGoods() {
        return goodsMapper.countGoods();
    }

    @Override
    public GoodDTO[] search(String gname) {
        return goodsMapper.search(gname);
    }

    @Override
    public BaseChartDTO[] getDayExp() {
        return goodsMapper.getDayExp();
    }

    @Override
    public BaseChartDTO[] getExpGood() {
        return goodsMapper.getExpGood();
    }
}
